#include<linux/module.h>
#include<linux/sched.h>
#include<linux/list.h>
#include<linux/kthread.h>
MODULE_LICENSE("GPL");

int my_function(void *argc)
{
	printk("in the kernel thread function.\n");
	printk("the my_current pid is:%d\n",current->pid);
	printk("out the kernel thread function.\n");
	return 0;
}
static int __init init_waitqueue_entry_init(void)
{
	struct task_struct *result;
	char namefrm[]="init_waitqueue_entry";
	wait_queue_t data;
	printk("into init_waitqueue_entry_init.\n");

	result=kthread_create_on_node(my_function,NULL,-1,namefrm);
	wake_up_process(result);

	if(data.private==NULL || data.func==NULL)
	{
		printk("the data has not been initialized\n");	
	}

	init_waitqueue_entry(&data,result);

	if(data.private == result && data.func !=NULL)
	{
		printk("the data has been initialized\n");	
		printk("the flags of the data is:%d\n",data.flags);
	}
	else
	{
		printk("the data has not been initialized\n");	
	}

	printk("the pid of new thread is:%d\n",result->pid);
	printk("the current pid is:%d\n",current->pid);
	printk("out init_waitqueue_entry_init.\n");
	return 0;
}
static void __exit init_waitqueue_entry_exit(void)
{
	printk("Goodbye init_waitqueue_entry\n");
}
module_init(init_waitqueue_entry_init);
module_exit(init_waitqueue_entry_exit);
